Micron Document
🎖️GitЯра🎖️


Displaying Raw • Download

core/network/src/commonMain/kotlin/org/meshtastic/core/network/HttpClientDefaults.kt 01cd54907d62cd90913d3d071b6bc240cae365ef (01cd5490) Text, 2.49 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.network

Tff7b72import T7ee787io.ktor.client.plugins.HttpRequestRetryConfig

T8b949e/**
* Shared HTTP client configuration used by both Android and Desktop Ktor `HttpClient` setups.
*
* These values are consumed by the platform-specific Koin modules (`NetworkModule` on Android, `DesktopKoinModule` on
* Desktop) when installing [io.ktor.client.plugins.HttpTimeout] and [io.ktor.client.plugins.HttpRequestRetry].
*/
Tff7b72object T56d364HttpClientDefaults Tb4b4b4{
T8b949e/** Timeout in milliseconds for connect and socket operations. */
Tff7b72const Tff7b72val Te6edf3TIMEOUT_MS Tff7b72= T79c0ff3T79c0ff0Te6edf3_000L

T8b949e/**
* Timeout in milliseconds for a whole request. Deliberately generous: api.meshtastic.org has been measured taking
* 20-60s to serve `github/firmware/list` and `resource/deviceHardware`, and callers use stale-while-revalidate
* caching so nothing user-facing waits on this deadline.
*/
Tff7b72const Tff7b72val Te6edf3REQUEST_TIMEOUT_MS Tff7b72= T79c0ff9T79c0ff0Te6edf3_000L

T8b949e/** Maximum number of automatic retries on server errors (5xx) and transient connection/IO failures. */
Tff7b72const Tff7b72val Te6edf3MAX_RETRIES Tff7b72= T79c0ff3

T8b949e/** Base URL for the Meshtastic public API. Installed via the `DefaultRequest` plugin. */
Tff7b72const Tff7b72val Te6edf3API_BASE_URL Tff7b72= Ta5d6ff"Ta5d6ffhttps://api.meshtastic.org/Ta5d6ff"
Tb4b4b4}

T8b949e/**
* Shared [io.ktor.client.plugins.HttpRequestRetry] policy for both engines.
*
* Retries on 5xx server errors and on transient connection/IO failures (dropped sockets, DNS blips, read timeouts) —
* the common failure mode on flaky cellular — with exponential backoff. [HttpClientDefaults.MAX_RETRIES] applies to
* both rules.
*/
Tff7b72fun Te6edf3HttpRequestRetryConfigTb4b4b4.Td2a8ffconfigureDefaultRetryTb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3retryOnServerErrorsTb4b4b4(Te6edf3maxRetries Tff7b72= Te6edf3HttpClientDefaultsTb4b4b4.Te6edf3MAX_RETRIESTb4b4b4)
Te6edf3retryOnExceptionTb4b4b4(Te6edf3maxRetries Tff7b72= Te6edf3HttpClientDefaultsTb4b4b4.Te6edf3MAX_RETRIESTb4b4b4, Te6edf3retryOnTimeout Tff7b72= Tff7b72trueTb4b4b4)
Te6edf3exponentialDelayTb4b4b4(Tb4b4b4)
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.05s